home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Topik / Topik - Disk 02 - Fonts and CLI Commands (19xx)(Topik Public Domain)(PD)[a][WB].zip / Topik - Disk 02 - Fonts and CLI Commands (19xx)(Topik Public Domain)(PD)[a][WB].adf / Source / mkidir.c < prev    next >
C/C++ Source or Header  |  1989-04-19  |  3KB  |  79 lines

  1. /* mkidir, creates a subdirectory ala ADOS makedir with the exception
  2. it adds a icon file for the directory, same command syntax 
  3. Donald Wahl 6-19-87                                                   */
  4.   #include <stdio.h>
  5.   #include <ctype.h>
  6.   #include "libraries/dos.h"
  7.   #include "libraries/dosextens.h"
  8.   #include "exec/types.h"
  9.   #include "exec/memory.h"
  10.   #include "functions.h"
  11.   
  12. /* data for one each plain directory .info file (WBDRAWER) */  
  13. /* opens at NO_ICON_POSITION to allow workbench to avoid overlap */
  14. UWORD infodat[173] = {   
  15. 0xE310,0x0001,0x0000,0x0000,0x0000,0x0000,0x0040,0x000D,
  16. 0x0004,0x0003,0x0001,0x0024,0x85B0,0x0000,0x0000,0x0000,
  17. 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  18. 0x0274,0x0000,0x0000,0x0000,0x0000,0x8000,0x0000,0x8000,
  19. 0x0000,0x0001,0x54E0,0x0000,0x0000,0x0000,0x0000,0x010B,
  20. 0x0017,0x012F,0x0079,0xFFFF,0x0000,0x0000,0x0240,0x027F,
  21. 0x0001,0x5554,0x0000,0x0000,0x0020,0x5958,0x0000,0x0000,
  22. 0x0000,0x0000,0x005A,0x0028,0xFFFF,0xFFFF,0x0001,0x0000,
  23. 0x0000,0x0000,0x0000,0x0000,0x0000,0x0040,0x000C,0x0002,
  24. 0x0001,0x4100,0x0300,0x0000,0x0000,0x0000,0x0000,0x0000,
  25. 0x0000,0x3FFF,0xFFFF,0xFFFF,0xFFFC,0x3C00,0x0000,0x0000,
  26. 0x003C,0x3CFF,0xFFFF,0xFFFF,0xFF3C,0x3CFF,0xFFFF,0xFFFF,
  27. 0xFF3C,0x3CFF,0xFF3F,0xFCFF,0xFF3C,0x3CFF,0xFF00,0x00FF,
  28. 0xFF3C,0x3CFF,0xFFFF,0xFFFF,0xFF3C,0x3CFF,0xFFFF,0xFFFF,
  29. 0xFF3C,0x3C00,0x0000,0x0000,0x003C,0x3FFF,0xFFFF,0xFFFF,
  30. 0xFFFC,0x0000,0x0000,0x0000,0x0000,0xFFFF,0xFFFF,0xFFFF,
  31. 0xFFFF,0xC000,0x0000,0x0000,0x0003,0xC3FF,0xFFFF,0xFFFF,
  32. 0xFFC3,0xC300,0x0000,0x0000,0x00C3,0xC300,0x0000,0x0000,
  33. 0x00C3,0xC300,0x00C0,0x0300,0x00C3,0xC300,0x00FF,0xFF00,
  34. 0x00C3,0xC300,0x0000,0x0000,0x00C3,0xC300,0x0000,0x0000,
  35. 0x00C3,0xC3FF,0xFFFF,0xFFFF,0xFFC3,0xC000,0x0000,0x0000,
  36. 0x0003,0xFFFF,0xFFFF,0xFFFF,0xFFFF };
  37.  
  38. main(argc,argv)
  39. int argc;
  40. char *argv[];
  41. {
  42.  
  43.  
  44.   struct FileLock *lock = NULL;
  45.   struct FileHandle *infofile = NULL; 
  46.   char iconname[120];
  47.     if(argc != 2)   /* check for one arg (dir name) */
  48.        showusage();
  49.        
  50.     lock = Lock(argv[1]);   
  51.     if(lock)
  52.          {  Write(Output(),"directory already exists\n",25l);
  53.             UnLock(lock);
  54.             exit(20);   }
  55.  
  56.     lock = CreateDir(argv[1]);
  57.     if(!lock)
  58.          {  Write(Output(),"Make directory failed\n",22l);
  59.             exit(20);   }
  60.      UnLock(lock);
  61.    /* makeup icon file name */  
  62.      strcpy(iconname,argv[1]);
  63.      strcat(iconname,".info");
  64.      
  65.     if ((infofile = Open(iconname, MODE_NEWFILE)) == NULL)
  66.          {  Write(Output(),".info file Open failure\n",24l);
  67.             exit(20);   }
  68.      Write(infofile,infodat,346l);       
  69.      Close(infofile);
  70.      exit(0);
  71.  
  72. }    
  73. showusage()
  74.     {
  75.       Write(Output(),"USAGE:\nmkidir directory_path\n",29l);
  76.       exit(0);
  77.     }
  78.  
  79.